home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10192 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  55 lines

  1. Newsgroups: comp.lang.c++,comp.lang.c++.mederated
  2. Path: bcc.ac.uk!news
  3. From: richard@nmr.ion.bpmf.ac.uk (Mr Richard Maunder)
  4. Subject: Problems with "multiple defined" at linking stage
  5. Sender: news@ucl.ac.uk (Usenet News System)
  6. Message-ID: <1996Mar6.144651.26841@ucl.ac.uk>
  7. Date: Wed, 6 Mar 1996 14:46:51 GMT
  8. Reply-To: richard@nmr.ion.bpmf.ac.uk
  9. Organization: Institute of Neurology NMR Research Unit, London, UK
  10. Keywords: C++,C,header
  11.  
  12. I am trying to build a C++ patch over a C function library, but am encountering some problems at the linking stage, where the ld reports : 
  13.  
  14. collect2: ld returned 2 exit status
  15. ld: /usr/tmp/cca176282.o: __imerrbuf: multiply defined
  16.  
  17. I presume this is caused by a multiple include in the code, but I cannot see a way round it.  The compiler (g++) makes no complaints when creating the object code.
  18.  
  19. The files I have are :
  20.  
  21.     1) unc_c++_patch .h - The header for the patch.  This had the standard :
  22.  
  23.         #ifndef UNC_CPLUSPLUS_PATCH
  24.         #define UNC_CPLUSPLUS_PATCH
  25.  
  26.         extern "C" {
  27.             #include "image.h"
  28.         }
  29.  
  30.         ......protyping for C++ methods.
  31.  
  32.         #endif
  33.  
  34.     in it. The file image.h is the header for the C function library.
  35.  
  36.     2) unc_c++_patch.cc - The methods for the C++ patch. Has a #include unc_c++_patch.h at the top.
  37.  
  38.     3) simple.cc - The actual program - again has unc_c++_patch.h at top.
  39.  
  40. I presume I should be able to compile unc_c++_patch.cc and simple.cc seperately and then link them, but won't the compiler include "image.h" both times - or is this the linkers job to sort this out ??  Even if I pass both .cc files to the compiler at the same time I get the same result.
  41.  
  42. I hope that I'm not being too stupid ! Any help gartefully recieved...Please CC tany replies o my e-mail address.
  43.  
  44. Thanks
  45.  
  46.  
  47. Richard
  48.   
  49.  
  50.     
  51.  
  52.  
  53.  
  54.  
  55.